package bdd.standalone.bean;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * Bean Video.
 * @author Guillaume Pocas & Jean-Fraçois Augé
 */
@Entity
@Table(name = "video")
public class Video {

	@Id
	@GeneratedValue
	@Column(name = "video_id")
	private int video_id;
	
	@Column(name = "video_name", unique = true, nullable = false, updatable = false)
	private String video_name;
	
	@ManyToOne
    @JoinColumn(name = "cam_id")
	private Camera camera;
	
	@ManyToMany(cascade = {CascadeType.ALL})
    @JoinTable(name="video_treatlist",
                joinColumns={@JoinColumn(name="treat_id")},
                inverseJoinColumns={@JoinColumn(name="video_id")})
    private Set<Treatment> treat_list = new HashSet<Treatment>();
	
	@Column(name = "video_timeBegin", nullable = false)
	private Date video_timeBegin;
	
	@Column(name = "video_timeEnd", nullable = false)
	private Date video_timeEnd;
	
	@Column(name = "video_dayBegin", nullable = false)
	private Date video_dayBegin;
	
	@Column(name = "video_dayEnd", nullable = false)
	private Date video_dayEnd;
	
	@Column(name = "video_weight", nullable = false, updatable = false)
	private float video_weight;
	
	/**
	 * Constructeur vide.
	 */
	public Video() {}
	
	/**
	 * Créer une nouvelle Video.
	 * @param name
	 * @param timeBegin
	 * @param timeEnd
	 * @param dayBegin
	 * @param dayEnd
	 * @param weight
	 */
	public Video(String name, Date timeBegin, Date timeEnd, Date dayBegin, Date dayEnd, float weight) {
		this.video_name = name;
		this.video_timeBegin = timeBegin;
		this.video_timeEnd = timeEnd;
		this.video_dayBegin = dayBegin;
		this.video_dayEnd = dayEnd;
		this.video_weight = weight;
	}

	public int getVideo_id() { return video_id;	}
	public void setVideo_id(int video_id) { this.video_id = video_id;	}

	public String getVideo_name() { return video_name;	}
	public void setVideo_name(String video_name) { this.video_name = video_name;	}

	public Camera getCamera() { return camera;	}
	public void setCamera(Camera camera) { this.camera = camera;	}

	public Date getVideo_timeBegin() { return video_timeBegin;	}
	public void setVideo_timeBegin(Date video_timeBegin) { this.video_timeBegin = video_timeBegin;	}

	public Date getVideo_timeEnd() { return video_timeEnd;	}
	public void setVideo_timeEnd(Date video_timeEnd) { this.video_timeEnd = video_timeEnd;	}

	public Date getVideo_dayBegin() { return video_dayBegin;	}
	public void setVideo_dayBegin(Date video_dayBegin) { this.video_dayBegin = video_dayBegin;	}

	public Date getVideo_dayEnd() { return video_dayEnd;	}
	public void setVideo_dayEnd(Date video_dayEnd) { this.video_dayEnd = video_dayEnd;	}

	public float getVideo_weight() { return video_weight;	}
	public void setVideo_weight(float video_weight) { this.video_weight = video_weight;	}

	public Set<Treatment> getTreat_list() { return treat_list;	}
	public void setTreat_list(Set<Treatment> treat_list) { this.treat_list = treat_list;	}
	
	@Override
	public String toString() { return getVideo_name(); }
	
}
